home *** CD-ROM | disk | FTP | other *** search
- Path: zetnet.co.uk!demon!barwick.demon.co.uk
- From: paul@barwick.demon.co.uk (Paul Stockton)
- Newsgroups: comp.lang.c++
- Subject: Visual C++ Scrollbar problem
- Date: Thu, 08 Feb 1996 15:08:20 GMT
- Message-ID: <311a10f3.599945@news.demon.co.uk>
- NNTP-Posting-Host: barwick.demon.co.uk
- X-NNTP-Posting-Host: barwick.demon.co.uk
- X-Newsreader: Forte Agent .99d/16.182
-
- Does anybody know why a horizontal scroll bar I have in my application
- continuously sends WM_HSCROLL messages AFTER I have let go of the
- mouse button. If I move the mouse off the scroll bar, the messages
- stop, but restart again as soon as I place the mouse back onto the
- scroll bar (that is without pressing the mouse button again!).
-
- I am convinced it is due to the fact that in my OnHScroll message
- handler I am performing quite a lengthy operation on receipt of a
- SB_LINELEFT or SB_LINERIGHT scroll bar code. I know this, because if
- I comment out the 'lengthy' code, it works fine.
-
- Because the message handler is being called whilst I am doing this
- 'lengthy operation' my application soon reports a stack overflow, so I
- included a flag to check as soon as the message handler is called and
- to return if it was set. This cured my stack overflow problem, but
- I'm no further forward in the multiple scroll message problem.
-
- Basically my question is, how do I get the scroll bar to send just one
- message when I click the scroll bar arrows or, if that is not
- possible, how do I perform a lengthy operation on receipt of a
- WM_HSCROLL message without the scroll bar sending tons of messages?
-
- Here's my OnHScroll message handler:
-
-
- void HitView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar*
- pScrollBar)
- {
- static BOOL Scrolling = FALSE; // scrolling flag
-
- if(Scrolling) return; // if busy, return immediately
- Scrolling = TRUE; // set to TRUE when 'lengthy
- op' in progress
-
- if (pScrollBar != NULL && pScrollBar->GetDlgCtrlID() ==
- IDC_HITSCROLL)
- {
- switch(nSBCode)
- {
- case SB_LINERIGHT:
-
- // lengthy operation
- break;
-
- case SB_LINELEFT:
-
- // another lengthy operation
- break;
- }
- }
-
- CFrameWnd::OnHScroll(nSBCode, nPos, pScrollBar);
-
- Scrolling = FALSE; // reset Scrolling flag
- }
-
-
- I would be grateful for any help.
-
- Steve Bentley
- Email: steve@barwick.demon.co.uk
-